import { doLogin } from "./doLogin";

export default {
  props: ["vcodeSrc"],
  data() {
    return {
      imgSrc: "",

      username: "",
      password: "",
      vcode: "",

      errorTip: "",
    };
  },
  computed: {
    values() {
      return {
        username: this.username,
        password: this.password,
        vcode: this.vcode,
      };
    },
  },
  // watch:{
  //   values(){
  //     this.errorTip = '';
  //   }
  // },
  created() {
    this.refreshVCode();
  },
  methods: {
    refreshVCode() {
      this.imgSrc = this.vcodeSrc + "?key=" + +new Date();
    },
    submit() {
      let isValid = doLogin.call(this, this.values);
      this.$emit("submit", isValid, this.values);
    },
  },
}
